package com.feihua.honest.adapter;
import android.widget.*;
import android.view.*;
import com.feihua.honest.bean.*;
import android.content.*;
import java.util.*;
import com.feihua.honest.*;
import android.view.View.*;

public class HonestAdapter extends BaseAdapter
{

	private ViewHolder viewHolder;
	private Context context;
	private List<Honest> data;
	
	public HonestAdapter(Context context,List<Honest> data){
		this.context=context;
		this.data=data;
	}

	public void sx()
	{
		
		notifyDataSetChanged();
		// TODO: Implement this method
	}
	
	@Override
	public int getCount()
	{
		// TODO: Implement this method
		return data.size();
	}

	@Override
	public Object getItem(int p1)
	{
		// TODO: Implement this method
		return null;
	}

	@Override
	public long getItemId(int p1)
	{
		// TODO: Implement this method
		return p1;
	}

	@Override
	public View getView(int position, View p2, ViewGroup p3)
	{
		if(p2==null){
			p2=LayoutInflater.from(context).inflate(R.layout.honest_item,null);
			viewHolder=new ViewHolder();
			viewHolder.tv_from_nick=p2.findViewById(R.id.tv_from_nick);
			viewHolder.tv_to_pic_name=p2.findViewById(R.id.tv_to_pic_name);
			viewHolder.tv_time=p2.findViewById(R.id.tv_time);
			p2.setTag(viewHolder);
		}else{
			viewHolder=(HonestAdapter.ViewHolder) p2.getTag();
		}
		final Honest honest=data.get(position);
		viewHolder.tv_time.setText(honest.getTime());
		viewHolder.tv_from_nick.setText(honest.getFromNick()+"("+honest.getFromQQ()+")");
		viewHolder.tv_to_pic_name.setText(honest.getTopicName());
		
		
		p2.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View p1)
				{
					ClipboardManager cmb = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
					cmb.setText(honest.getFromQQ());//复制命令
					
					Toast.makeText(context,"已复制QQ号到剪贴板",Toast.LENGTH_SHORT).show();
					// TODO: Implement this method
				}
			});
		// TODO: Implement this method
		return p2;
	}
	
	class ViewHolder{
		TextView tv_from_nick,tv_to_pic_name,tv_time;
		
	}
	
	
	
}
